package com.gmail.dmitryustimov.ms.java7.observer.classic.demo.subj1subsc10event10;

import java.util.ArrayList;
import java.util.List;

public class Subject {

    private List<Observer> subscribers;

    public Subject() {
        subscribers = new ArrayList<>();
    }

    public void registerObserver(Observer o) {
        subscribers.add(o);
    }

    public void removeObserver(Observer o) {
        subscribers.remove(o);
    }

    public void notifyObservers(Event event) {
        for (Observer o: subscribers) {
            o.update(event);
        }
    }

    public void makeEvent1() {
        notifyObservers(new Event1(""));
    }

    public void makeEvent2() {
        notifyObservers(new Event2(""));
    }

    public void makeEvent3() {
        notifyObservers(new Event3(""));
    }

    public void makeEvent4() {
        notifyObservers(new Event4(""));
    }

    public void makeEvent5() {
        notifyObservers(new Event5(""));
    }

    public void makeEvent6() {
        notifyObservers(new Event6(""));
    }

    public void makeEvent7() {
        notifyObservers(new Event7(""));
    }

    public void makeEvent8() {
        notifyObservers(new Event8(""));
    }

    public void makeEvent9() {
        notifyObservers(new Event9(""));
    }

    public void makeEvent10() {
        notifyObservers(new Event10(""));
    }
}
